home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / EMULATOR / GBDK_BIN / examples / c / init < prev    next >
Text File  |  1996-04-15  |  975b  |  61 lines

  1. #include<stdio.h>
  2.  
  3. typedef struct { int codes[3]; char name[6]; } Word;
  4.  
  5. Word words[] = {
  6.     1, 2, 3, "if",
  7.     { { 4, 5 }, { 'f', 'o', 'r' } },
  8.     6, 7, 8, {"else"},
  9.     { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
  10.     { 0 },
  11. }, *wordlist = words;
  12.  
  13. int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };
  14. int *y[] = { x[0], x[1], x[2], 0 };
  15.  
  16.  
  17. main()
  18. {
  19.     int i, j;
  20.  
  21.     for (i = 0; y[i]; i++) {
  22.         for (j = 0; y[i][j]; j++)
  23.             printf(" %d", y[i][j]);
  24.         printf("\n");
  25.     }
  26.     f();
  27.     g(wordlist);
  28.     return 0;
  29. }
  30.  
  31. f() {
  32.     static char *keywords[] = {"if", "for", "else", "while", 0, };
  33.     char **p;
  34.  
  35.     for (p = keywords; *p; p++)
  36.         printf("%s\n", *p);
  37. }
  38.  
  39. g(p)
  40. Word *p;
  41. {
  42.     int i;
  43.  
  44.     for ( ; p->codes[0]; p++) {
  45.         for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
  46.             printf("%d ", p->codes[i]);
  47.         printf("%s\n", p->name);
  48.     }
  49.     h();
  50. }
  51.  
  52. h()
  53. {
  54.     int i;
  55.  
  56.     for (i = 0; i < sizeof(words)/sizeof(Word); i++)
  57.         printf("%d %d %d %s\n", words[i].codes[0],
  58.             words[i].codes[1], words[i].codes[2],
  59.             &words[i].name[0]);
  60. }
  61.